package com.macro.mall.portal.controller;

import com.macro.mall.common.api.CommonPage;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.portal.service.TiTrainingVideoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * TiTrainingVideo的路由接口服务
 * 
 * @author 
 *
 */
@Slf4j
@RestController
@RequestMapping("TiTrainingVideoController")
@Api(tags = "课程视频", description = "课程视频")
public class TiTrainingVideoController {

	/** TiTrainingVideoService服务 */
	@Autowired
	private TiTrainingVideoService tiTrainingVideoService;

    /**
     * 查询所有数据的方法
     * @param
     * @return
     */
    @GetMapping(value = "/list", produces = {"application/json;charset=UTF-8"})
    public CommonResult find(@ApiParam(value = "课程分组id",  required = false) @RequestParam(value = "courseId", required = false) String courseId,
                             @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                             @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize) {
        return CommonResult.success(CommonPage.restPage(tiTrainingVideoService.find(courseId, pageNum, pageSize)));
    }

    /**
     * 通过id查询数据的方法
     * @param id
     * @return
     */
    @GetMapping(value = "/getById", produces = {"application/json;charset=UTF-8"})
    public CommonResult findOne(@RequestParam(name="id") Integer id) {
        return CommonResult.success(tiTrainingVideoService.findOne(id));
    }


}
